﻿<html class="pixel-ratio-1">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>添加课程</title>
    <meta name="viewport" content="initial-scale=1, maximum-scale=1">
    <link rel="shortcut icon" href="/favicon.ico">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <!-- Google Web Fonts -->
    <!--<link rel="stylesheet" href="//g.alicdn.com/msui/sm/0.5.8/css/sm.min.css">
    <link rel="stylesheet" href="//g.alicdn.com/msui/sm/0.5.8/css/sm-extend.min.css">
    <link rel="stylesheet" type="text/css" href="//at.alicdn.com/t/font_1464664061_1061604.css">-->
    <!--<link href="css/reset.css" rel="stylesheet" type="text/css">-->
    <link rel="stylesheet" href="https://res.wx.qq.com/open/libs/weui/0.4.3/weui.min.css">
    <link href="/ViewMob/js/layer/need/layer.css" rel="stylesheet" />
    <script src="/ViewMob/js/layer/layer.m.js"></script>
    <script type='text/javascript' src='//g.alicdn.com/sj/lib/zepto/zepto.min.js' charset='utf-8'></script>
    <script src="/ViewMob/js/avalon.mobile.js"></script>
    <script src="/ViewMob/js/ComFunJS.js"></script>
    <script src="/ViewMob/js/zepto.md5.js"></script>
    <script>
        model = avalon.define({
            $id: "ADDKC",
            modelData: { "KCName": "", "Class": "", "StartDate": "2016-09-26", "EndDate": "2016-12-26", "Remark": "" },
            SKInfo: { "Week": 1, "SKHour": 1, "KCLength": 45, "ClassRoom": "", "isfortnightly": "", "SKMinute": 10 },
            SKList: [{ "Week": 1, "SKHour": 1, "KCLength": 45, "ClassRoom": "", "isfortnightly": "", "SKMinute": 10 }],
            weekDay: [{ name: "周一", day: 1 }, { name: "周二", day: 2 }, { name: "周三", day: 3 }, { name: "周四", day: 4 }, { name: "周五", day: 5 }, { name: "周六", day: 6 }, { name: "周日", day: 0 }],
            Hour: [{ name: "30分钟", hour: 30 }, { name: "45分钟", hour: 45 }, { name: "1小时", hour: 60 }, { name: "2小时", hour: 120 }, { name: "3小时", hour: 180 }, { name: "4小时", hour: 240 }],
            AddSKInfo: function () {
                model.SKList.push(model.SKInfo.$model);
            }, AddKCInfo: function () {
                if (model.modelData.KCName == "") {
                    ComFunJS.winwarning("请填写课程名称")
                    return;
                }
                if (model.modelData.KCName == "") {
                    ComFunJS.winwarning("请填写班级")
                    return;
                }
                if (model.SKList.size() == 0) {
                    ComFunJS.winwarning("请设置上课信息")
                    return;
                }
                var msg = "";
                model.SKList.forEach(function (item) {
                    if (!item.ClassRoom) {
                        msg = "请输入上课教室";
                    }
                    item.isfortnightly = item.isfortnightly ? 1 : 0;
                })
                if (msg) { 
                    ComFunJS.winwarning(msg);
                    return;
                }
                model.modelData.Remark =JSON.stringify( model.SKList.$model); 
                $.post("/API/VIEWAPI.ashx?Action=JSZS_ADDKC&r=" + Math.random(), { "P1": JSON.stringify(model.modelData.$model) }, function (data) {
                    var data = $.parseJSON(data);
                    if (data.ErrorMsg == "") {
                        ComFunJS.winsuccess("添加成功")
                    }
                    else {
                        ComFunJS.winwarning(data.ErrorMsg)
                    }
                })
            }
        })
    </script>
</head>
<body style="background:#fbf9fe" ms-controller="ADDKC">
    <div class="container" id="container">
        <div class="bd" style="margin-bottom:4rem;">
            <div class="weui_cells_title">设置课程信息</div>
            <div class="weui_cells">
                <div class="weui_cell">
                    <div class="weui_cell_hd"><label for="" class="weui_label">课程名称</label></div>
                    <div class="weui_cell_bd weui_cell_primary">
                        <input class="weui_input" type="text" ms-duplex="modelData.KCName" placeholder="必填">
                    </div>

                </div>
                <div class="weui_cell">
                    <div class="weui_cell_hd"><label for="" class="weui_label">上课班级</label></div>
                    <div class="weui_cell_bd weui_cell_primary">
                        <input class="weui_input" type="text" ms-duplex="modelData.Class" placeholder="必填,多个班级用逗号隔开">
                    </div>

                </div>
                <div class="weui_cell">
                    <div class="weui_cell_hd"><label for="" class="weui_label">开课日期</label></div>
                    <div class="weui_cell_bd weui_cell_primary">
                        <input class="weui_input" type="date" ms-duplex="modelData.StartDate">
                    </div>

                </div>
                <div class="weui_cell">
                    <div class="weui_cell_hd"><label for="" class="weui_label">结课日期</label></div>
                    <div class="weui_cell_bd weui_cell_primary">
                        <input class="weui_input" type="date" ms-duplex="modelData.EndDate">
                    </div>

                </div>
            </div>
            <div class="weui_cells_title">设置教学计划<span style="float: right; color: #44A9FF;" ms-click="AddSKInfo()">添加上课信息</span></div>
            <div class="weui_cells" ms-repeat-el="SKList">
                <div class="weui_cell weui_cell_select">
                    <div class="weui_cell_bd weui_cell_primary">
                        <select class="weui_select" ms-duplex="el.Week">
                            <option ms-repeat-item="weekDay" ms-attr-value="item.day" ms-selected="el.Week==item.day">{{item.name}}</option>
                        </select>
                    </div>
                </div>
                <div class="weui_cell">
                    <div class="weui_cell_hd"><label for="" class="weui_label">上课时间</label></div>
                    <div class="weui_cell_bd weui_cell_primary">
                        <select class="weui_select " style="float:left;width:40%;" ms-duplex="el.SKHour">
                            <option value="1">1</option>
                            <option value="2">2</option>
                            <option value="3">3</option>
                            <option value="4">4</option>
                            <option value="5">5</option>
                            <option value="6">6</option>
                            <option value="7">7</option>
                            <option value="8">8</option>
                            <option value="9">9</option>
                            <option value="10">10</option>
                            <option value="11">11</option>
                            <option value="12">12</option>
                            <option value="13">13</option>
                            <option value="14">14</option>
                            <option value="15">15</option>
                            <option value="16">16</option>
                            <option value="17">17</option>
                            <option value="18">18</option>
                            <option value="19">19</option>
                            <option value="20">20</option>
                            <option value="21">21</option>
                            <option value="22">22</option>
                            <option value="23">23</option>
                            <option value="24">24</option>
                        </select>
                        <select class="weui_select" style="float: left; width: 40%" ms-duplex="el.SKMinute">
                            <option value="0">0</option>
                            <option value="10">10</option>
                            <option value="20">20</option>
                            <option value="30">30</option>
                            <option value="40">40</option>
                            <option value="50">50</option>
                        </select>
                    </div>

                </div>
                <div class="weui_cell">
                    <div class="weui_cell_hd"><label for="" class="weui_label">课程时长</label></div>
                    <div class="weui_cell_bd weui_cell_primary">
                        <select class="weui_select" style="float: left; width: 40%" ms-duplex="el.KCLength">
                            、
                            <option value="30">30分钟</option>
、                            <option value="45">45分钟</option>
                            <option value="60">1小时</option>
                            <option value="120">2小时</option>
                        </select>
                    </div>

                </div>
                <div class="weui_cell">
                    <div class="weui_cell_hd"><label for="" class="weui_label">上课教室</label></div>
                    <div class="weui_cell_bd weui_cell_primary">
                        <input class="weui_input" type="text" placeholder="必填" ms-duplex="el.ClassRoom">
                    </div>

                </div>
                <div class="weui_cell weui_cell_switch">
                    <div class="weui_cell_hd weui_cell_primary">是否间隔</div>
                    <div class="weui_cell_ft">
                        <input class="weui_switch" type="checkbox" ms-duplex="el.isfortnightly==1">
                    </div>
                </div>
            </div>


        </div>
    </div>
    <div class="btn-list-bc">
        <div style="padding:.6rem 2rem;">
            <a class="weui_btn weui_btn_primary" ms-click="AddKCInfo()" id="showTooltips" style="border-radius: 2rem; background-color: #44A9FF; ">保存预设</a>
        </div>

    </div>
    <style>
        .btn-list-bc {
            background: #fff;
            position: fixed;
            bottom: 0;
            left: 0;
            width: 100%;
            border-top: 1px solid #F1EFF2;
        }
    </style>
    
</body>
</html>